﻿@{
    Layout = "_LayoutSub";
    ViewData["Title"] = "元数据字段表";
}

<el-container>
    <avue-crud :data="tableData" :option="option" :permission="hasPermission" :page.sync="pageOption" :table-loading="loading"
               v-on:refresh-change="refreshChange"
               v-on:row-save="handleRowSave"
               v-on:row-update="handleRowUpdate"
               v-on:row-del="handleRowDel"
               v-on:search-change="searchChange"
               v-on:search-reset="resetChange"
               :cell-style="cellStyle"
               v-on:on-load="onMyLoad">
    </avue-crud>
</el-container>

@section Scripts {
    <script>
        var yenoDicData = [{ label:`否`,value:false },{label: `是`,value:true },];
        new Vue({
            el: '#app',
            mixins: [curdMixin],
            data() {
                return {
                    tableId:`@ViewBag.tableId`,
                    name: "FieldMetadata",
                    pageUrl: `/FieldMetadata/pages`,
                    addUrl: `/FieldMetadata/add`,
                    editUrl: `/FieldMetadata/update`,
                    deleteUrl: `/FieldMetadata/delete`,
                    pageOption: {
                             pageSize: 200
                         },
                    option: {
                        searchShowBtn: Permissions.avePermission(`FieldMetadata:searchBtn`),
                        refreshBtn: Permissions.avePermission(`FieldMetadata:searchBtn`),
                        menuWidth: '350',
                        rowKey: 'id',
                        searchShow: false,
                        viewBtn: false,
                        labelWidth:"150",
                        columnBtn: false,
                        cellBtn:true,
                        // cellBtn:true,
                         dialogType: "drawer",// dialogType	表格弹窗方式	string	dialog/drawer	dialog
                         // pageOption: {
                         //     pageSize: 200
                         // },
                        column: [
                            { prop: "id", label: `${this.i18n.t('primary_key')}`, search: false, hide: true, type: "number", display: false, showColumn: false, },
                            // { prop: "tableMetaId", label: `表Id`, slot: true,span:24, search: false, searchValue: `@ViewBag.tableId`, hide: true, clearable: true, disabled: true, rules: [{ required: true, trigger: "blur", message: `${this.i18n.t('pleaseenter')}` }], },
                            { prop: "dbColumnName", label: `列名`, slot: true, search: false, hide: false, width: '120', clearable: true, rules: [{ required: true, trigger: "blur", message: `${this.i18n.t('pleaseenter')}` }], },
                            { prop: "propertyName", label: `别名`,cell:true,  slot: true, search: false, hide: false, width: '120', clearable: true, rules: [{ required: true, trigger: "blur", message: `${this.i18n.t('pleaseenter')}` }], },
                            { prop: "description", label: `说明`,cell:true,cell:true,  slot: true,/* type:'textarea', */width:'120',search:false,hide:false,clearable:true },

                            { prop: "dataType", label: `数据类型`, slot: true, search: false, hide: false, width: '90', clearable: true, rules: [{ required: true, trigger: "blur", message: `${this.i18n.t('pleaseenter')}` }], },
                            { prop: "propertyType", label: `实体类类型`,cell:true,  slot: true, search: false, hide: false, width: '120', clearable: true, rules: [{ required: true, trigger: "blur", message: `${this.i18n.t('pleaseenter')}` }], },
                            { prop: "length", label: `字段长度`, slot: true, search: false, hide: false, width: '70', clearable: true, rules: [{ required: true, trigger: "blur", message: `${this.i18n.t('pleaseenter')}` }], },
                            // { prop: "fieldSort", label: `排序`, search: false, hide: false, type: "number", width: '70', value: 10, step: 10, min: 10, max: 20000, },

                            { prop: "isNullable", label: `允许空`, cell:true,search: false, hide: false, value: true, type: "select", button: true, dicData: yenoDicData, width: '80', },
                            { prop: "isPrimarykey", label: `主键`, search: false, hide: false, value: false, type: "select", button: true, dicData: yenoDicData, width: '50', },
                            { prop: "isIdentity", label: `自增`, search: false, hide: false, value: false, type: "select", button: true, dicData: yenoDicData, width: '50', },

                            { prop: "isSearch", label: "搜索项", cell:true,slot: true, search: false, hide: false, value: false, type: "select", button: true, dicData: yenoDicData, width: '80' },
                            { prop: "columnDisplay", label: "列表中显示", cell:true,slot: true, search: false, hide: false, value: false, type: "select", button: true, dicData: yenoDicData, width: '100' },
                            { prop: "addDisplay", label: "新增时显示", cell:true,slot: true, search: false, hide: false, value: false, type: "select", button: true, dicData: yenoDicData, width: '100' },
                            { prop: "editDisplay", label: "编辑时显示", cell:true,slot: true, search: false, hide: false, value: false, type: "select", button: true, dicData: yenoDicData, width: '100' },
                            { prop: "cellType", label: `控件类型`, search: false, hide: false, value: false, type: "select", button: true, dicData: yenoDicData, width: '80', },
                            { prop: "isSystemReserved", label: `系统保留`, search: false, hide: false, value: false, type: "select", button: true, dicData: yenoDicData, width: '80', },

                            // { prop: "width", label: "对应列的宽度", slot: true, search: false, hide: true, clearable: true },
                            // { prop: "minWidth", label: "对应列的最小宽度", slot: true, search: false, hide: true, clearable: true },
                            // { prop: "fixed", label: "列是否固定在左侧或者右侧", slot: true, search: false, hide: true, value: false, type: "select", button: true, dicData: yenoDicData, width: '100' },
                            // { prop: "sortable", label: "对应列是否可以排序", slot: true, search: false, hide: true, value: false, type: "select", button: true, dicData: yenoDicData, width: '100' },
                            // { prop: "formatter", label: "用来格式化列内容", slot: true, search: false, hide: true, clearable: true },
                            // { prop: "overHidden", label: "当内容过长被隐藏时显示 tooltip", slot: true, search: false, hide: true, value: false, type: "select", button: true, dicData: yenoDicData, width: '100' },
                            // { prop: "align", label: "对齐方式", slot: true, search: false, hide: true, clearable: true },
                            // { prop: "headerAlign", label: "表头对齐方式", slot: true, search: false, hide: true, clearable: true },
                            // { prop: "filters", label: "数据过滤的选项", slot: true, search: false, hide: true, value: false, type: "select", button: true, dicData: yenoDicData, width: '100' },
                            // { prop: "search", label: "是否为搜索项", slot: true, search: false, hide: true, value: false, type: "select", button: true, dicData: yenoDicData, width: '100' },
                            // { prop: "searchValue", label: "搜索项初始化值", slot: true, search: false, hide: true, clearable: true },
                            // { prop: "searchPlaceholder", label: "搜索项辅助文字", slot: true, search: false, hide: true, clearable: true },
                            // { prop: "searchSpan", label: "搜索项框栅列", slot: true, search: false, hide: true, clearable: true },
                            // { prop: "searchOrder", label: "搜索项位置排序", slot: true, search: false, hide: true, clearable: true },
                            // { prop: "searchGutter", label: "搜索项框间距", slot: true, search: false, hide: true, clearable: true },
                            // { prop: "searchRange", label: "搜索项为范围搜索", slot: true, search: false, hide: true, value: false, type: "select", button: true, dicData: yenoDicData, width: '100' },
                            // { prop: "searchType", label: "搜索项的类型", slot: true, search: false, hide: true, clearable: true },
                            // { prop: "searchLabelWidth", label: "搜索项标题宽度", slot: true, search: false, hide: true, clearable: true },
                            // { prop: "searchClearable", label: "搜索项清除", slot: true, search: false, hide: true, value: false, type: "select", button: true, dicData: yenoDicData, width: '100' },
                            // { prop: "searchMultiple", label: "搜索项是否多选", slot: true, search: false, hide: true, value: false, type: "select", button: true, dicData: yenoDicData, width: '100' },
                            // { prop: "searchTags", label: "搜索项将选中值按文字的形式展示", slot: true, search: false, hide: true, value: false, type: "select", button: true, dicData: yenoDicData, width: '100' },
                            // { prop: "searchLabelPosition", label: "搜索项标题位置", slot: true, search: false, hide: true, clearable: true },
                            // { prop: "display", label: "弹出表单是否显示", slot: true, search: false, hide: true, value: false, type: "select", button: true, dicData: yenoDicData, width: '100' },
                            // { prop: "disabled", label: "弹出表单是否禁止", slot: true, search: false, hide: true, value: false, type: "select", button: true, dicData: yenoDicData, width: '100' },
                            // { prop: "addDisabled", label: "表单新增时项是否禁止", slot: true, search: false, hide: true, value: false, type: "select", button: true, dicData: yenoDicData, width: '100' },
                            // { prop: "editDisabled", label: "表单编辑时项是否禁止", slot: true, search: false, hide: true, value: false, type: "select", button: true, dicData: yenoDicData, width: '100' },
                            // { prop: "viewDisabled", label: "表单查看时项是否禁止", slot: true, search: false, hide: true, value: false, type: "select", button: true, dicData: yenoDicData, width: '100' },
                            // { prop: "addDisplay", label: "表单新增时项是否显示", slot: true, search: false, hide: true, value: false, type: "select", button: true, dicData: yenoDicData, width: '100' },
                            // { prop: "editDisplay", label: "表单编辑时项是否显示", slot: true, search: false, hide: true, value: false, type: "select", button: true, dicData: yenoDicData, width: '100' },
                            // { prop: "viewDisplay", label: "表单查看时项是否显示", slot: true, search: false, hide: true, value: false, type: "select", button: true, dicData: yenoDicData, width: '100' },
                            // { prop: "resizable", label: "拖动改变宽度", slot: true, search: false, hide: true, value: false, type: "select", button: true, dicData: yenoDicData, width: '100' }

                        ],
                    },

                }
            },
            created() {
                this.selectRow = {};
                // ViewBag.tableId
            },
            methods: {
                onMyLoad(page, done){
                    this.searchParams={tableMetaId:this.tableId};
                        this.onLoad(page, done);
                },
                cellStyle({ row, column, rowIndex, columnIndex }) {
                    // if (columnIndex == 8||columnIndex == 9||columnIndex == 10||columnIndex ==11||columnIndex == 12||columnIndex == 13||columnIndex == 14) {
                    //     if (row.isNullable == 0||
                    //     row.isPrimarykey == 0||
                    //     row.isIdentity == 0||
                    //     row.isSearch == 0||
                    //     row.columnDisplay == 0||
                    //     row.addDisplay == 0||
                    //     row.editDisplay == 0||
                    //     row.isSystemReserved == 0) {
                    //         return { color: '#409eff', }
                    //     }
                    //     else {
                    //         return { color: '#f56c6c', }
                    //     }
                    // }
                },
            }
        });
    </script>

}